#ifndef OBJECTDETECTION_H_INCLUDED
#define OBJECTDETECTION_H_INCLUDED

#include "common.h"
#include "matrixManagement.h"
#include "objectManagement.h"
#include "pixel.h"

#define TOLERANCEH 200.0            //!< Hue tolerance value
#define TOLERANCES 200.0            //!< Saturation tolerance value
#define TOLERANCEL 20.0             //!< L tolerance value
#define TOLERANCEab 10.0            //!< a&b tolerance value

void objectDetection (Pixel** mat, Taille size, double tolerance, ObjectManager* objs);
bool testAround(Uint16 li, Uint16 col, bool** mask, double tolerance, PixelHSI** mat, Taille size);
void exploreAround(Object* obj, Uint16 li, Uint16 col, bool** mask, double tolerance, PixelLab** colMat, PixelHSI** mat, Taille size);
ObjectManager* startDetection(Pixel** mat, Taille sz, double tolerance);

/*inline bool test (PixelLab px1, PixelLab px2) {return !(abs(px1.L - px2.L)>TOLERANCEL or
                                                        abs(px1.a - px2.a) + abs(px1.b - px2.b)>TOLERANCEab);}*/

//! \brief Tests the association of two pixels
//!
//! \param px1 First pixel to test
//! \param px2 Second pixel to test
//! \param toleranceI The intensity tolerance value
//! \return Wether or not px1 is associated with px2
//!
inline bool test (PixelHSI px1, PixelHSI px2, double toleranceI)
{return abs(px1.H - px2.H)<TOLERANCEH and abs(px1.S - px2.S)<TOLERANCES and abs(px1.I - px2.I)<toleranceI;}

#endif // OBJECTDETECTION_H_INCLUDED
